#pragma once

#include <memory>
#include <sstream>
#include <string>
#include <vector>

#include "common/macros.h"
#include "planner/operator.h"

namespace optimizer {

class Format {
 private:
  bool first_ = true;
  std::stringstream ss_;
  std::vector<std::string> prefix_;

  std::string FormatOperatorTree(const std::shared_ptr<Operator>& op, bool is_last = true);

  std::string ToStringInternal(const std::shared_ptr<Operator>& op);

 public:
  Format() = default;
  DISALLOW_COPY_AND_MOVE(Format)

  static std::string ToString(const std::shared_ptr<Operator>& op);
};

}  // namespace optimizer